import { Injectable } from '@nestjs/common';
import { ConfigService } from '@nestjs/config';

@Injectable()
export class ConfigurationService {

  constructor(private configService: ConfigService) {}

  get(key: string): string {
    return this.configService[key];
  }
  get mysqlHost():string {
    return this.configService.get('MYSQL_HOST');
  }
  get mysqlPort():number {
    return this.configService.get('MYSQL_PORT');
  }
  get mysqlUser():string {
    return this.configService.get('MYSQL_USER');
  }
  get mysqlPassword():string {
    return this.configService.get('MYSQL_PASSWORD');
  }
  get mysqlDatabase():string {
    return this.configService.get('MYSQL_DATABASE');
  }

  get mysqlConfig(){
    return {
      host: this.mysqlHost,
      port: this.mysqlPort,
      username: this.mysqlUser,
      password: this.mysqlPassword,
      database: this.mysqlDatabase,
      autoLoadEntities: true,
      synchronize: true,
      logging: true,
    }
  }

}